require 'rexml/document'

RAILS_ROOT = "#{File.dirname(__FILE__)}/../.." unless defined?(RAILS_ROOT) 

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  
  @@resource_file = File.join(RAILS_ROOT, 'config\resources.xml')
  @@resources = REXML::Document.new(File.open(@@resource_file))
  @@current_language = "ru_RU"

  # Return true if some user is logged in, false otherwise.
  def logged_in?
    not session[:user_id].nil?
  end

  # Return version of resource (string) localized for current language
  def L10n(resource_name)
    @@resources.elements["//#{resource_name}/#{@@current_language}"].text
  end

end

